package com.dukun.mybatis.config;

import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Mybatis-plus 配置类
 *
 * author：dukun
 * date：2021/10/20
 */
@Configuration
public class MybatisPlusConfig {

    /**
     * 使用了通用枚举，用户返回给前段的时候序列化枚举类
     *
     * @return 枚举类里面标注了@JsonVale注解的值
     */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer customizer() {
        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
    }
}
